package com.artPreter.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.artPreter.pojo.Artwork;
import com.artPreter.pojo.Result;
import com.artPreter.service.IArtworkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 艺术品表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-11-14
 */
@RestController
@RequestMapping("/artwork")
public class ArtworkController {

    @Autowired
    private IArtworkService artworkService;

    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody Artwork artwork){
        IPage<Artwork> artworkIPage = artworkService.getPage(currentPage,size,artwork);
        return Result.success(artworkIPage);
    }

    /**
     * 添加艺术家
     * @param
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody Artwork artwork){
        artworkService.add(artwork);
        return Result.success();
    }

    /**
     * 修改艺术机构
     * @param
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody Artwork artwork){
        artworkService.edit(artwork);
        return Result.success();
    }

    /**
     * 软删除艺术机构
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody Artwork artwork){
        artworkService.delete(artwork);
        return Result.success();
    }


    /**
     * 添加到艺术品关联表
     * @param
     * @return
     */
    @PostMapping("/addToRelative")
    public Result addToRelative(@RequestBody Artwork artwork){
        artworkService.addToRelative(artwork);
        return Result.success();
    }

    /**
     * 删除关联艺术品
     * @param
     * @return
     */
    @PostMapping("/removeArtworkRelative")
    public Result removeArtworkRelative(@RequestBody Artwork artwork){
        artworkService.removeArtworkRelative(artwork);
        return Result.success();
    }

    /**
     * 未观关联艺术品分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPageNoRelative")
    public Result getPageNoRelative(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody Artwork artwork){
        IPage<Artwork> artworkIPage = artworkService.getPageNoRelative(currentPage,size,artwork);
        return Result.success(artworkIPage);
    }

    /**
     * 未关联作品在线艺术片分页
     * @param currentPage
     * @param size
     * @param artwork
     * @return
     */
    @PostMapping("/getPageNoRelativeOnline")
    public Result getPageNoRelativeOnline(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody Artwork artwork){
        IPage<Artwork> artworkIPage = artworkService.getPageNoRelativeOnline(currentPage,size,artwork);
        return Result.success(artworkIPage);
    }

    /**
     * 已关联艺术品在线分页
     * @param currentPage
     * @param size
     * @param artwork
     * @return
     */
    @PostMapping("/getPageRelativeOnline")
    public Result getPageRelativeOnline(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody Artwork artwork){
        IPage<Artwork> artworkIPage = artworkService.getPageRelativeOnline(currentPage,size,artwork);
        return Result.success(artworkIPage);
    }

    /**
     * 添加到艺术品关联表
     * @param
     * @return
     */
    @PostMapping("/addToOnlineRelative")
    public Result addToOnlineRelative(@RequestBody Artwork artwork){
        artworkService.addToOnlineRelative(artwork);
        return Result.success();
    }

    /**
     * 已关联艺术品分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPageRelative")
    public Result getPageRelative(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody Artwork artwork){
        IPage<Artwork> artworkIPage = artworkService.getPageRelative(currentPage,size,artwork);
        return Result.success(artworkIPage);
    }

}
